﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NTFS
{
    public partial class Form1 : Form
    {
        SistemaNTFS sys = new SistemaNTFS();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            sys.Inicia();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Mft test = sys.PegaMftPublic("$bitmap");
            MessageBox.Show(test.ToString());
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Arquivo arq;
            arq = sys.Openfile("teste.txt", "administrador");
            MessageBox.Show(arq.Conteudo+'\n'+arq.Info.ToString());
        }

        private void btnGravaArq_Click(object sender, EventArgs e)
        {
            Arquivo arq = new Arquivo();
            arq.Caminho = "~";
            arq.Conteudo = "12345";
            arq.Info = new Mft();
            arq.Info.Nome = "$testegravacao";
            arq.Info.Tipo = 'a';
            //arq.Info.Users.Add( new user { nome = "sistema", permissoes = 6 });
            sys.GravaArquivo(arq,0);
        }

        private void btnExcluir_Click(object sender, EventArgs e)
        {
            Arquivo arq = sys.Openfile(3,"sistema");
            Arquivo dir = sys.Openfile(0,"sistema");
            sys.DeletaArquivo(arq, dir);
        }
    }
}
